package com.cstp.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author watts
 */
public class QuestionEnum {

    @Getter
    public enum Type {
        /**
         * 类型
         */
        SINGLE(1, "单选题"),
        MULTI(2, "判断题"),
        QA(3, "多选题");

        Type(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @EnumValue
        private final int code;
        private final String desc;

        public static Type of(int code) {
            return Arrays.stream(Type.values())
                         .filter(t -> t.code == code)
                         .findFirst()
                         .orElseThrow();
        }
    }
}
